<?php

/**
 * This is the model class for table "reply".
 *
 * The followings are the available columns in table 'reply':
 * @property string $reply_id
 * @property string $reply_msgtype
 * @property string $reply_data
 * @property integer $reply_is_del
 * @property integer $reply_is_active
 * @property integer $reply_ins_user_id
 * @property string $reply_ins_user_name
 * @property integer $reply_ins_date
 * @property integer $reply_up_user_id
 * @property string $reply_up_user_name
 * @property integer $reply_up_date
 * @property integer $reply_del_user_id
 * @property string $reply_del_user_name
 * @property integer $reply_del_date
 */
class Reply extends EActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	 
	public static $msgtype = array(
			'text' => '文本消息',
			'music' => '音乐消息',
			'news' => '图文消息',
		);
	
	public $reply_arr = NULL;
	public $data = NULL;

	public function tableName()
	{
		return '{{reply}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('reply_msgtype, reply_data, reply_is_del, reply_is_active, reply_ins_user_id, reply_ins_user_name, reply_ins_date, reply_up_user_id, reply_up_user_name, reply_up_date', 'required'),
			array('reply_is_del, reply_is_active, reply_ins_user_id, reply_ins_date, reply_up_user_id, reply_up_date, reply_del_user_id, reply_del_date', 'numerical', 'integerOnly'=>true),
			array('reply_msgtype', 'length', 'max'=>5),
			array('reply_data', 'length', 'max'=>1000),
			array('reply_ins_user_name, reply_up_user_name, reply_del_user_name', 'length', 'max'=>80),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('reply_id, reply_msgtype, reply_data, reply_is_del, reply_is_active, reply_ins_user_id, reply_ins_user_name, reply_ins_date, reply_up_user_id, reply_up_user_name, reply_up_date, reply_del_user_id, reply_del_user_name, reply_del_date', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'reply_id' => 'Reply',
			'reply_msgtype' => 'Reply Msgtype',
			'reply_data' => 'Reply Data',
			'reply_is_del' => 'Reply Is Del',
			'reply_is_active' => 'Reply Is Active',
			'reply_ins_user_id' => 'Reply Ins User',
			'reply_ins_user_name' => 'Reply Ins User Name',
			'reply_ins_date' => 'Reply Ins Date',
			'reply_up_user_id' => 'Reply Up User',
			'reply_up_user_name' => 'Reply Up User Name',
			'reply_up_date' => 'Reply Up Date',
			'reply_del_user_id' => 'Reply Del User',
			'reply_del_user_name' => 'Reply Del User Name',
			'reply_del_date' => 'Reply Del Date',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('reply_id',$this->reply_id,true);
		$criteria->compare('reply_msgtype',$this->reply_msgtype,true);
		$criteria->compare('reply_data',$this->reply_data,true);
		$criteria->compare('reply_is_del',$this->reply_is_del);
		$criteria->compare('reply_is_active',$this->reply_is_active);
		$criteria->compare('reply_ins_user_id',$this->reply_ins_user_id);
		$criteria->compare('reply_ins_user_name',$this->reply_ins_user_name,true);
		$criteria->compare('reply_ins_date',$this->reply_ins_date);
		$criteria->compare('reply_up_user_id',$this->reply_up_user_id);
		$criteria->compare('reply_up_user_name',$this->reply_up_user_name,true);
		$criteria->compare('reply_up_date',$this->reply_up_date);
		$criteria->compare('reply_del_user_id',$this->reply_del_user_id);
		$criteria->compare('reply_del_user_name',$this->reply_del_user_name,true);
		$criteria->compare('reply_del_date',$this->reply_del_date);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Reply the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
